class Solution {
    public int removeDuplicates(int[] nums) {
        int q=2;
        int p=2;
        while(q<nums.length)
        {
            if(nums[p-2]!=nums[q])
            {
                nums[p]=nums[q];
                p++;
            }
            q++;
        }
        return p;
    }
}
